Part 3. Fonts Tool Box The Fonts toolbox (FONTB.BAS), included with this version of BASIC, contains a set of routines that perform font-management tasks such as registering, loading, selecting, and printing fonts on the screen. Nine font files are supplied. Courier fonts in COURA.FON, COURB.FON, and COURE.FON, Helvetica fonts in HELVA.FON, HELVB.FON and HELVE.FON, and Times Roman fonts in TMSRA.FON, TMSRB.FON and TMSRE.FON. Each of these files contains six font sizes. Besides these two font files, the Fonts toolbox will work with any standard Windows bitmap .FON file. To use the Fonts toolbox, you must compile and link the FONTASM.OBJ and FONTB.BAS modules into a .LIB or .QLB library file. Once this library exists, you can use it just like any other library. The Fonts toolbox can be used independently of the Presentation Graphics toolbox to draw graphics text. Several of the procedures use the font-header information defined in the user-defined type FontInfo. This type is defined in the FONTB.BI header file. This file also contains definitions for constants that can be used as arguments to the procedures described in this section. Using these constants in place of hand-coded numbers makes your program cleaner and easier to debug. Font Error Codes If an error occurs during the execution of a font function or sub procedure, the variable FontErr will contain a non-zero value. For non-BASIC errors, the error numbers can be tested using numerics or constants as defined in the FONTB.BI header file. The meaning of a non-BASIC error is shown in Table 3.9. ----------------------------------------------------------------------------- Number Constant name Type of error ---------------------------------------------------------------------------- FontNum The location of the font in the registered list or the loaded list. Ascent The pixel distance from the character baseline to the top of the character box. Points The point size of the current font as defined in the LoadFont% function. Number Constant name Type of error ---------------------------------------------------------------------------- PixWidth The width of the character bitmap. A value of 0 specifies a proportional font. A nonzero value specifies the pixel width of the characters in a fixed-space font. PixHeight The height of the character bitmap. Leading The number of blank lines at the top of the character definition to act as leading between lines. AvgWidth The average width of characters in pixels. MaxWidth The pixel width of the widest character in the font. FileName The filename from which the font was loaded. The filename has the extension .FON. Number Constant name Type of error ---------------------------------------------------------------------------- The filename has the extension .FON. FaceName The name of the typeface (for example, Helvetica, Courier) taken from the filename. Note When using the GetFontInfo procedure, be sure you have access to the .FON file on disk so that it can find the FontNum, FileName, and FaceName values for the currently selected font. For more information on the elements of the variable type FontInfo, see documentation on font file format in Chapter 7, "File Formats" in the Programmer's Reference, which is part of the Microsoft Windows Software Development Kit.